<?php 
class HPagesModulesAdmin {
	function getInstancesByPane($page_id, $pane) {
		$result = array();
		$a = HSql::fetch2Array(HSql::getData('portal_pages_modules',"WHERE page_id = '$page_id' AND pane_name = '$pane'"));
		if (count($a) > 0) {
			for ($i = 0; $i < count($a); $i++) {
				// check if it is the system module
				// Get module id
				$b = HSql::fetch2Array(HSql::getData('portal_modules_instances',"WHERE id = '".$a[$i]['module_instance_id']."'"));
				$module_id = $b[0]['module_id'];
				
				// Get is System
				$c = HSql::fetch2Array(HSql::getData('portal_modules',"WHERE id = '".$module_id."'"));
				$isSystem = $c[0]['is_system'];
							
				// Validate
				if ($isSystem == 0) $result[] = $a[$i];
			}
		}
		return $result;
	}
	
	function getModuleAlias($instance_id) {
		// Get module name
		$module_name = HModules::getModuleNameById($instance_id);
		// Get friendly Name
		$a = HSql::fetch2Array(HSql::getData('portal_modules_instances',"WHERE id = '$instance_id'"));						$friendly_name = $a[0]['friendly_name'];	
		return $module_name.'_'.$friendly_name;
	}
}
?>